package com.geotmt.billingcenter.modules.statis.mapper;

import com.geotmt.billingcenter.common.entry.ConsumeStatisEntry;
import com.geotmt.billingcenter.common.vo.consume.ConsumeStatisVo;
import com.geotmt.billingcenter.common.vo.params.ParamsConsume;
import com.geotmt.billingcenter.modules.statis.mapper.provider.ConsumeStatisProvider;
import org.apache.ibatis.annotations.*;

import java.util.Date;
import java.util.List;

/**
 * @Description DAO类
 * @Author      yanghanwei
 * @Mail        yanghanwei@geotmt.com
 * @Date        2019/3/27 18:25
 * @Version     v1
 **/
@Mapper
public interface ConsumeStatisMapper {

    /**
     * 消耗list(最细力度)
     * @param obj
     * @return
     */
    @SelectProvider(type = ConsumeStatisProvider.class, method = "consumeStatisList")
    List<ConsumeStatisVo> consumeStatisList(ParamsConsume obj);

    /**
     * 消耗历史的量统计
     * @param obj
     * @return
     */
    @SelectProvider(type = ConsumeStatisProvider.class, method = "hisConsumeStatis")
    ConsumeStatisVo hisConsumeStatis(ParamsConsume obj);

    /**
     * 消耗list(用户)
     * @param obj
     * @return
     */
    @SelectProvider(type = ConsumeStatisProvider.class, method = "consumeStatisCompanyList")
    List<ConsumeStatisVo> consumeStatisCompanyList(ParamsConsume obj);

    /**
     * 删除某天的消耗统计
     * @param dayFlag
     * @param deleteTime
     * @return
     */
    @DeleteProvider(type = ConsumeStatisProvider.class, method = "deleteConsumeStatisForDay")
    int deleteConsumeStatis(@Param(value = "dayFlag") String dayFlag,
                            @Param(value = "deleteTime") Date deleteTime);

    /**
     * 删除某段时间的消耗统计
     * @param startDay
     * @param endDay
     * @param deleteTime
     * @return
     */
    @DeleteProvider(type = ConsumeStatisProvider.class, method = "deleteConsumeStatisForDate")
    int deleteConsumeStatis2(@Param(value = "startDay") String startDay,
                             @Param(value = "endDay") String endDay,
                             @Param(value = "deleteTime") Date deleteTime);

    /**
     * 更新统计报表中的相关维度id信息
     * @param startDay
     * @param endDay
     * @param id
     * @return
     */
    @UpdateProvider(type = ConsumeStatisProvider.class, method = "updateConsumeStatis")
    int updateConsumeStatis(@Param(value = "startDay") String startDay,
                            @Param(value = "endDay") String endDay,
                            @Param(value = "id") Integer id);

    /**
     * 更新某天的金额
     * @param cuserId
     * @param interfaceId
     * @param dayFlag
     * @param money
     * @return
     */
    @UpdateProvider(type = ConsumeStatisProvider.class, method = "updateConsumeMoney")
    int updateConsumeMoney(@Param(value = "cuserId") Integer cuserId,
                           @Param(value = "interfaceId") Integer interfaceId,
                           @Param(value = "dayFlag") String dayFlag,
                           @Param(value = "money") Double money);

    /**
     * 批量插入统计数据
     * @param subConsumeStatisList
     */
    @InsertProvider(type = ConsumeStatisProvider.class, method = "batchInsertStatis")
    void batchInsertStatis(@Param(value = "subConsumeStatisList")List<ConsumeStatisEntry> subConsumeStatisList);

    /**
     * 更新某天的金额(根据用户id和接口类型)
     * @param cuserId
     * @param interfaceType
     * @param dayFlag
     * @param money
     * @return
     */
    @UpdateProvider(type = ConsumeStatisProvider.class, method = "updateConsumeMoney2")
    int updateConsumeMoney2(@Param(value = "cuserId") Integer cuserId,
                            @Param(value = "interfaceType") String interfaceType,
                            @Param(value = "dayFlag") String dayFlag,
                            @Param(value = "money") Double money);

    /**
     * 最细维度消耗统计List的总计
     * @param obj
     * @return
     */
    @SelectProvider(type = ConsumeStatisProvider.class, method = "consumeStatisTotal")
    ConsumeStatisVo consumeStatisTotal(ParamsConsume obj);
}
